//
//  DetailRotatingViewController.m
//  FinApp
//
//  Created by Victor Leandro Fernandez Rodrigo on 11/11/11.
//  Copyright (c) 2011 FIB-Fàcultat d'informàtica de Barcelona. All rights reserved.
//


#import "DetailRotatingViewController.h"
#import "Defines.h"

@implementation DetailRotatingViewController

@synthesize distaceLabel =			distaceLabel_;
@synthesize addressLabel =          addressLabel_;
@synthesize priceLabel  =           priceLabel_;
@synthesize showRouteLabel =		showRouteLabel_;
@synthesize checkBoxImage =			checkBoxImage_;
@synthesize checkImage =			checkImage_;


@synthesize distanceString =		distanceString_;
@synthesize priceString =           priceString_;
@synthesize addressString =			addressString_;


- (void)dealloc {
	
	[distaceLabel_ release];		distaceLabel_ = nil;
	[addressLabel_ release];		addressLabel_ = nil;
	[showRouteLabel_ release];		showRouteLabel_ = nil;
	[checkBoxImage_ release];		checkBoxImage_ = nil;
	[checkImage_ release];			checkImage_ = nil;
	
    [priceString_ release];         priceString_ = nil;
	[distanceString_ release];		distanceString_ = nil;
	[addressString_ release];		addressString_ = nil;
	
    [super dealloc];
	
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	
    [super viewDidLoad];
	
	// Cadena del nombre y la distancia

	[distaceLabel_ setText:distanceString_];
	// TextView fonts
	[addressLabel_ setTextColor:[UIColor whiteColor]];
	[addressLabel_ setText:addressString_];
    [priceLabel_ setText:priceString_];
	
	[showRouteLabel_ setText:NSLocalizedString(@"_rotating_view_show_route_label", @"")];
	[showRouteLabel_ setTextColor:[UIColor whiteColor]];
	[checkImage_ setHidden:YES];
	
}


#pragma mark -
#pragma mark Redefinicion de metodos

- (NSString*)GetMyNameTag {
	
	return addressString_;
	
}

- (NSString*)GetMyDistanceTag {
	
	return distanceString_;
	
}

#pragma mark -
#pragma mark Metodos definidos en la interfaz

- (IBAction)showPath:(id)sender {
	
	NSLog(@"showing Path");
	
	if (mIsSelected == NO) {

		// Se muestra el banne de instrucciones
		mIsSelected = YES;
		[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(showInstrucctionView) userInfo:nil repeats:NO];
		[checkImage_ setHidden:NO];
		
	} else {

		// Se oculta el banne de instrucciones
		mIsSelected = NO;
		[checkImage_ setHidden:YES];
	}
	
}

#pragma mark -
#pragma mark Metodos privados


- (void)showInstrucctionView {
	
	// Mostrando el banner de instrucciones
	[self.view.window addSubview:instructionView_.view];
	
	if (mIsLandScapeForInstr == YES) {
		
		[instructionView_ changeOrientations:YES];
		
	} else {
		
		[instructionView_ changeOrientations:NO];
		
	}
	
	[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(hideInstrucctionView) userInfo:nil repeats:NO];
}

- (void)hideInstrucctionView {
	
	// Ocultando el banner de instrucciones	
	[instructionView_.view removeFromSuperview];
	
}

@end
